<?php
header('Content-Type: text/html; charset=utf8');
//echo time();
echo json_encode('龙')."龙";
echo "<hr>";
echo json_encode('虎')."虎";
echo "<hr>";
echo json_encode('单')."单";
echo "<hr>";
echo json_encode('双')."双";
echo "<hr>";
echo json_encode('合')."合";
echo "<hr>";
echo json_encode('充值')."充值";
echo "<hr>";
echo json_encode('提现')."提现";
echo "<hr>";

function get_res(){
    $login_url = "http://www.bwlc.net/bulletin/prevtrax.html";
    $curlj = curl_init();
    $timeout = 5;
    curl_setopt($curlj, CURLOPT_URL, $login_url);
    curl_setopt($curlj, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curlj, CURLOPT_CONNECTTIMEOUT, $timeout);
    $contents = curl_exec($curlj);
    //file_put_contents('kaijiang.html',$contents);
    curl_close($curlj);
    //$contents=file_get_contents('kaijiang.html');
    preg_match("/<table class=\"tb\"[^>]*?>(.*?)<\/table>/s",$contents,$match);
    $tr=$match[1];
    preg_match_all("/<tr class=\"[^>]*?>(.*?)<\/tr>/s",$tr,$match);
    $td=$match[1];
    $new_data=array();
    foreach($td as $k=>$v){
        $v=preg_match_all("/<td>(.*?)<\/td>/s",$v,$match);
        list($number,$res,$time)=$match[1];
        $new_data[$k]=array(
            'number'=>$number,
            'res'=>$res,
            'time'=>strtotime($time),
        );
    }
    return $new_data;
}

$new_data=get_res();


var_dump($new_data);
